package com.ruoyi.system.util;

import java.util.ArrayList;
import java.util.List;

public class ParkingLot {
    private List<Car> cars;


    public ParkingLot() {
        cars = new ArrayList<>();
    }


    public void park(Car car) {
        cars.add(car);
    }


    public void addCar(Car car) {
        cars.add(car);
    }

    // 其他管理车辆信息的方法

    public void calculateFee(Car car) {
        // 计算停车费用的逻辑
    }


    public void leave(Car car) {
        cars.remove(car);
    }


    public List<Car> getCars() {
        return cars;
    }

    public long getJiSuan(long jinchangbaitina, long jinchangwanshnag) {
        ParkingLot parkingLot = new ParkingLot();
        ChargeCalculator chargeCalculator = new ChargeCalculator();
        // 模拟车辆进入停车场
        Car car1 = new Car("白天", System.currentTimeMillis());
        parkingLot.park(car1); // 模拟车辆离开停车场
        long leaveTime1 = System.currentTimeMillis() + jinchangbaitina * 60 * 60 * 1000; //白天价格
        int charge1 = chargeCalculator.calculateCharge(car1, leaveTime1);
        int chargejine1=charge1>30?30:charge1;
        System.out.println(car1.getLicensePlate() + "停车费用为：" +(charge1>30?"已上线固定金额为30":charge1) + "元"); // 模拟车辆进入停车场
        Car car2 = new Car("晚上", System.currentTimeMillis());
        parkingLot.park(car2); // 模拟车辆离开停车场
        long leaveTime2 = System.currentTimeMillis() + jinchangwanshnag * 60 * 60 * 1000;
        int charge2 = chargeCalculator.calculateIMD(car2, leaveTime2);//晚上价格
        int chargejine2=charge2>30?30:charge2;
        System.out.println(car2.getLicensePlate() + "停车费用为：" + (charge2>=30?"已上线固定金额为30":charge2) + "元");
        long jiner = chargejine1 + chargejine2;

        long zjg=jiner>=30?30:jiner;
        System.out.println("白天与晚上总共费用:"+(zjg>=30?"已达到上线固定金额为30":zjg));
        return zjg;
    }

    //判断第一天时间完整日期
    public long getday(long jinlai, long jinxiaoshi) {
        long jin = 0;
        if (jinlai <= 30) {
            jin = jinxiaoshi;
        } else {
            jin = jinxiaoshi + 1;
        }
        return jin;
    }


    //判断当天的出库时间
    public long getZuihou(long getday,long chuqu) {
        long xiaos = 0;
        if (getday>=30){
            xiaos=chuqu+1;
        }else{
            xiaos=chuqu;
        }
        return xiaos;
    }


    //判断最后一天时间完整日期
    public long getEvening(long chuqu, long chukuxiaoshi) {
        long chu = 0;
        if (chuqu >= 30) {
            chu = chukuxiaoshi;
        } else {
            chu = chukuxiaoshi-1;
        }
        return chu;
    }

    //当天计算方式
    public List getThef(long jin, long chukuxiaoshi) {
        long jinchangbaitina = 0;//白天的小时
        long jinchangwanshnag = 0;//晚上的小时
        for (; jin <= 23; jin++) {
            if (jin==chukuxiaoshi){
                break;
            }
            if (jin >= 8 && jin < 18) {
                jinchangbaitina++;
            } else{
                jinchangwanshnag++;
                if (chukuxiaoshi == jin) {
                    break;
                }
            }
        }
        List list = new ArrayList();
        list.add(jinchangbaitina);
        list.add(jinchangwanshnag);
        return list;
    }

    //计算第一天
    public List getThefirstday(long jin, long chukuxiaoshi) {
        long jinchangbaitina = 0;//白天的小时
        long jinchangwanshnag = 0;//晚上的小时
        for (; jin <= 23; jin++) {
            if (jin >= 8 && jin < 18) {
                jinchangbaitina++;
            } else {
                jinchangwanshnag++;
            }
        }
        List list = new ArrayList();
        list.add(jinchangbaitina);
        list.add(jinchangwanshnag);
        return list;
    }

    //计算最后一天
    public List getLastday(long chu) {
        long zuihoubaitian = 0;//白天的小时
        long zuihouwanshang = 0;//晚上的小时
        for (; chu >=0; chu--) {
            if (chu >= 8 && chu < 18) {
                zuihoubaitian++;
            } else {
                zuihouwanshang++;
            }
        }
        List list = new ArrayList();
        list.add(zuihoubaitian);
        list.add(zuihouwanshang);
        return list;
    }

    //计算停车时间
    public List getParkingtime(long minutes) {
        List list = new ArrayList();
        long hours = 0;
        hours = minutes / 60;
        long remainingMinutes = minutes % 60;
        list.add(hours);
        System.out.println("停车时间（小时）: " + hours + "小时" + (remainingMinutes > 0 ? remainingMinutes + "分钟" : ""));
        return list;
    }


    public List<Long> getBaitian(List<Long> diyi, List<Long> zuihou) {
        Long baitian = diyi.get(0) + zuihou.get(0);
        Long wangshang = diyi.get(1) + zuihou.get(1);
        List<Long> list = new ArrayList();
        list.add(baitian);
        list.add(wangshang);
        return list;
    }
}
